/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.estoque.Telas;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author note
 */
public class Principal extends javax.swing.JFrame {

    /**
     * Creates new form Principal
     */
    public Principal() {
        initComponents();
    }
    
    Clientes cliente;
    Produtos produto;
    Fornecedores fornecedor;
    RegistrarVenda registraVenda;
    ConsultarVenda consultaVenda;
    
    
    
    /** Método para exibir a tela de Clientes */
    private void mostrarClientes(){
        if(cliente == null){
            cliente = new Clientes();
            cliente.setVisible(true);
        }
        else{
            cliente.setVisible(true);
            cliente.setState(JFrame.NORMAL);
        }
    }
    /** Método para exibir a tela de Fornecedores */
    private void mostrarFornecedores(){
        if(fornecedor == null){
            fornecedor = new Fornecedores();
            fornecedor.setVisible(true);
        } else{
            fornecedor.setVisible(true);
            fornecedor.setState(JFrame.NORMAL);
        }
    }
    
    /** Método para exibir a tela de Produtos */
    private void mostrarProdutos(){
        if(produto == null){
            produto = new Produtos();
            produto.setVisible(true);
        } else{
            produto.setVisible(true);
            produto.setState(JFrame.NORMAL);
        }
    }
    
    /** Método para exibir a tela de Registrar Vendas */
    private void mostrarRegistrarVendas(){
        if(registraVenda == null){
            registraVenda = new RegistrarVenda();
            registraVenda.setVisible(true);
        } else{
            registraVenda.setVisible(true);
            registraVenda.setState(JFrame.NORMAL);
        }
    }
    
    /** Método para exibir a tela de Consultar Vendas */
    private void mostrarConsultaVendas(){
        if(consultaVenda == null){
            consultaVenda = new ConsultarVenda();
            consultaVenda.setVisible(true);
        } else{
            consultaVenda.setVisible(true);
            consultaVenda.setState(JFrame.NORMAL);
        }
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        menuOpcoes = new javax.swing.JMenu();
        menuSobre = new javax.swing.JMenuItem();
        menuSair = new javax.swing.JMenuItem();
        menuCadastros = new javax.swing.JMenu();
        menuCadastraClientes = new javax.swing.JMenuItem();
        menuCadastraFornecedores = new javax.swing.JMenuItem();
        menuCadastraProdutos = new javax.swing.JMenuItem();
        menuVendas = new javax.swing.JMenu();
        menuRegistrarVenda = new javax.swing.JMenuItem();
        menuConsultarVenda = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema de Constole de Estoque");

        menuOpcoes.setText("Opções");

        menuSobre.setText("Sobre");
        menuSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSobreActionPerformed(evt);
            }
        });
        menuOpcoes.add(menuSobre);

        menuSair.setText("Sair");
        menuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSairActionPerformed(evt);
            }
        });
        menuOpcoes.add(menuSair);

        jMenuBar1.add(menuOpcoes);

        menuCadastros.setText("Cadastros");

        menuCadastraClientes.setText("Clientes");
        menuCadastraClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastraClientesActionPerformed(evt);
            }
        });
        menuCadastros.add(menuCadastraClientes);

        menuCadastraFornecedores.setText("Fornecedores");
        menuCadastraFornecedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastraFornecedoresActionPerformed(evt);
            }
        });
        menuCadastros.add(menuCadastraFornecedores);

        menuCadastraProdutos.setText("Produtos");
        menuCadastraProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastraProdutosActionPerformed(evt);
            }
        });
        menuCadastros.add(menuCadastraProdutos);

        jMenuBar1.add(menuCadastros);

        menuVendas.setText("Vendas");

        menuRegistrarVenda.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F6, 0));
        menuRegistrarVenda.setText("Registrar Venda");
        menuRegistrarVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuRegistrarVendaActionPerformed(evt);
            }
        });
        menuVendas.add(menuRegistrarVenda);

        menuConsultarVenda.setText("Consultar Venda");
        menuConsultarVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarVendaActionPerformed(evt);
            }
        });
        menuVendas.add(menuConsultarVenda);

        jMenuBar1.add(menuVendas);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 279, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSairActionPerformed
        System.exit(0);
    }//GEN-LAST:event_menuSairActionPerformed

    private void menuSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSobreActionPerformed
        JOptionPane.showMessageDialog(null, "Sistema de Controle de Estoque por: Dayan Costa");
    }//GEN-LAST:event_menuSobreActionPerformed

    private void menuRegistrarVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuRegistrarVendaActionPerformed
        mostrarRegistrarVendas();
       // dispose();
    }//GEN-LAST:event_menuRegistrarVendaActionPerformed

    private void menuConsultarVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultarVendaActionPerformed
        mostrarConsultaVendas();
      //  dispose();
    }//GEN-LAST:event_menuConsultarVendaActionPerformed

    private void menuCadastraClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastraClientesActionPerformed
        mostrarClientes();
       // dispose();
    }//GEN-LAST:event_menuCadastraClientesActionPerformed

    private void menuCadastraFornecedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastraFornecedoresActionPerformed
        mostrarFornecedores();
      //  dispose();
    }//GEN-LAST:event_menuCadastraFornecedoresActionPerformed

    private void menuCadastraProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastraProdutosActionPerformed
        mostrarProdutos();
      //  dispose();
    }//GEN-LAST:event_menuCadastraProdutosActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem menuCadastraClientes;
    private javax.swing.JMenuItem menuCadastraFornecedores;
    private javax.swing.JMenuItem menuCadastraProdutos;
    private javax.swing.JMenu menuCadastros;
    private javax.swing.JMenuItem menuConsultarVenda;
    private javax.swing.JMenu menuOpcoes;
    private javax.swing.JMenuItem menuRegistrarVenda;
    private javax.swing.JMenuItem menuSair;
    private javax.swing.JMenuItem menuSobre;
    private javax.swing.JMenu menuVendas;
    // End of variables declaration//GEN-END:variables
}
